<?php
$this->headTitle('Quản lý game', 'append');
?>
<div class="grid">
    <div class="breadcrumbs">
        <a class="item-1" href="/index">Trang chủ</a> › 
        <a class="item-2" href="/admin/game"><?php $title = $this->headTitle(); if(isset($title[0])) echo $title[0]; ?></a>
        <div class="clear-both"></div>
    </div>
        <table border="0" cellspacing="0" cellpadding="0" width="100%">
            <thead>
                <tr>
                    <td class="column">STT</td>
                    <td class="column">ID</td>
                    <td class="column">Tên game</td>
                    <td class="column">Hình ảnh</td>
                    <td class="column">Danh mục</td>
                    <td class="column">Trạng thái</td>
                    <td class="column">
                        <?php if($this->acl->checkResource($this->auth,'admin','game','add')){ ?>
                            <a class="bnt-add" href="<?php echo $this->url(array('module'=>'admin', 'controller'=>'game', 'action'=>'add'));?>">
                                Thêm mới
                            </a>
                        <?php }else{ ?>
    						Chức năng
                        <?php } ?>
                    </td>
                </tr>
            </thead>
            <tbody>
                <?php
                    $stt = 1;
                    foreach ($this->gameList as $game){
                ?>
                <tr class="row row-<?php echo $stt;?>">
                    <td class="column text-align-center"><?php echo $stt;?></td>
                    <td class="column text-align-center"><span class="blue"><?php echo $game['gameId'];?></span></td>
                    <td class="column">
                        <?php if($this->acl->checkResource($this->auth,'admin','game','edit')){ ?>
							<a href="<?php echo $this->url(array('module'=>'admin', 'controller'=>'game', 'action'=>'edit', 'id'=>$game['gameId']));?>" title="Sửa thông tin">
								<?php echo $game['gameName'];?>
							</a>
                        <?php }else{ ?>
							<span class="blue"><?php echo $game['gameName'];?></span>
						<?php } ?>
                    </td>
                    <td class="column text-align-center">
                        <?php if($this->acl->checkResource($this->auth,'admin','game','edit')){ ?>
							<a href="<?php echo $this->url(array('module'=>'admin', 'controller'=>'game', 'action'=>'edit', 'id'=>$game['gameId']));?>" title="Sửa thông tin">
								<img src="<?php echo $game['gameImg']; ?>" alt="<?php echo $game['gameName'];?>" title="<?php echo $game['gameName'];?>" height="60px"/>
							</a>
                        <?php }else{ ?>
							<img src="<?php echo $game['gameImg']; ?>" alt="<?php echo $game['gameName'];?>" title="<?php echo $game['gameName'];?>" height="60px"/>
						<?php } ?>
                    </td>
                    <td class="column text-align-left"><?php echo $game['catName'];?></td>
                    <td class="column text-align-center">
                        <?php
                            if($game['status'] == 1){
                                echo '<img src="image/icons/icon_check.png" alt="Đang hoạt động" title="Đang hoạt động" border="0"/>';
                            }else{
                                echo '<img src="image/icons/icon_uncheck.png" alt="Đã Khóa" title="Đã khóa" border="0"/>';
                            }
                        ?>
                    </td>
                    <td class="column text-align-center">
                        <?php if($this->acl->checkResource($this->auth,'admin','game','cache')){ ?>
                            <a class="icon icon-cache" href="<?php echo $this->url(array('module'=>'admin', 'controller'=>'game', 'action'=>'cache', 'id'=>$game['gameId']));?>" title="Xóa cache game">
                                <img src="image/icons/icon_cache.png" alt="delete cache" border="0"/>
                            </a>
                        <?php 
                            }
                            if($this->acl->checkResource($this->auth,'admin','game','email')){ ?>
                            <a class="icon icon-email" href="<?php echo $this->url(array('module'=>'admin', 'controller'=>'game', 'action'=>'email', 'id'=>$game['gameId']));?>" title="Email report" onclick="return emailReport('<?php echo $game['gameName']." (".$game['gameId'].")";?>');">
                                <img src="image/icons/icon_email.png" alt="Email report" border="0"/>
                            </a>
                            <script type="text/javascript">
                                function emailReport(title)
                                {
                                    var r=confirm("Bạn muốn gửi mail cho game "+title+"!")
                                    if (r==true){
                                        return true;
                                    }else{
                                        return false;
                                    }
                                }
                            </script>
                        <?php 
                            }
                            if($this->acl->checkResource($this->auth,'admin','game','edit')){ ?>
                            <a class="icon icon-edit" href="<?php echo $this->url(array('module'=>'admin', 'controller'=>'game', 'action'=>'edit', 'id'=>$game['gameId']));?>" title="Sửa thông tin game">
                                <img src="image/icons/icon_edit.png" alt="edit game" border="0"/>
                            </a>
                        <?php 
                            }
                            if($this->acl->checkResource($this->auth,'admin','game','delete')){
                                if($this->gameCheck['gameId'] != $game['gameId']){
                        ?>
                    			<a class="icon icon-delete" href="<?php echo $this->url(array('module'=>'admin', 'controller'=>'game', 'action'=>'delete', 'id'=>$game['gameId']));?>" title="Xóa game">
                                    <img src="image/icons/icon_delete.png" alt="delete game" border="0"/>
                                </a>
                        <?php 
                                }
                            } 
                        ?>
                    </td>
                </tr>
                <?php
                    ++$stt; 
                    } 
                ?>
            </tbody>
        </table>
</div>
